<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of field_model
 *
 * @author hoa
 */
class home_model extends CI_Model{
    //put your code here
    public function __construct() {
        parent::__construct();
    }
    
    public function getField() {
        $data = $this->db->query("select * from field");
        return $data->result_array();
    }
    
    public function getPath() {
        $query = $this->db->query("select l.id, l.title, p.modified_date, substr(m.description, 1,200) short_description, m.description
            from learning_path l, path_version p, path_meta m
            where l.id=p.learning_path_id AND m.id=p.path_meta_id
            order by p.version");
        return $query->result_array();
    }
    
    public function getPathByFieldId($id) {
        $query = $this->db->query("select l.id, l.title, p.modified_date, substr(m.description, 1,200) short_description, m.description
            from learning_path l, path_version p, path_meta m
            where l.id=p.learning_path_id AND m.id=p.path_meta_id AND l.field_id= " . $id ."
            order by p.version");
        return $query->result_array();
    }
    
    public function getPathByTagId($id) {
        $query = $this->db->query("select l.id, l.title, p.modified_date, substr(m.description, 1,200) short_description, m.description
            from learning_path l, path_version p, path_meta m, path_has_tag h, tag t
            where l.id=p.learning_path_id AND m.id=p.path_meta_id AND
                    l.id=h.learning_path_id AND h.tag_id=t.id AND t.id= " . $id ."
            order by p.version");
        return $query->result_array();
    }
    
    public function getTag() {
        $data = $this->db->query("select * from tag");
        return $data->result_array();
    }
    
    public function getPopularPath() {
        $data = $this->db->query("select * from popular_path order by path_order");
        
    }
}

/* End of file home_model.php */
/* Location: ./application/models/home_model.php */